package manager
{
	import util.GameTimer;

	/**
	 * 时间管理类。
	 * @author luguo-bin
	 */
	public class TimerManager
	{
		private static var _items:Array = new Array();

		public static function addTimer(timer:GameTimer):void
		{
			var index:int = _items.indexOf(timer);

			if(index == -1)
			{
				_items.push(timer);
			}
		}

		public static function removeTimer(timer:GameTimer):void
		{
			var index:int = _items.indexOf(timer);

			if(index >= 0)
			{
				_items.splice(index, 1);
			}
		}

		public static function run():void
		{
			for(var key:String in _items)
			{
				(_items[key] as GameTimer).enterFrame();
			}
		}

		public static function clear():void
		{
			for(var key:String in _items)
			{
				(_items[key] as GameTimer).stop();
			}
		}
	}
}